package cn.funeralobjects.upms.entity;

import cn.funeralobjects.common.jpa.entity.BaseCloudJpaEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.util.List;

/**
 * @author FuneralObjects
 * Create date: 2020/5/27 4:05 PM
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@Entity
@DynamicUpdate
@DynamicInsert
@Table(name = "t_cus_path")
@NamedEntityGraph(name = "ECustomPath.withRoles", attributeNodes = {@NamedAttributeNode("roles")})
public class ECustomPath extends BaseCloudJpaEntity<Integer> {
    /**
     * 自定义路径
     */
    private String url;
    /**
     * 范围值
     */
    private String scope;
    /**
     * 关联的配置角色
     */
    @ManyToMany
    @JoinTable(name = "t_cus_path_role",
            joinColumns = @JoinColumn(name = "cus_path_id"),
            inverseJoinColumns = @JoinColumn(name = "role_id")
    )
    private List<ERole> roles;
}
